SleekPHP.styles.SleekCMS = {
	run: function () {
		if ($('#login-page').length) {
			this.loginNavigation();
			this.emptyLoginBoxes();
			this.themeSwitcher();

			$('#circle-stage').threeDCircle();
		}

		$('#admin-navigation form').togglableFormFields();
	}, 

	themeSwitcher: function () {
		var html = '<nav id="login-theme-switcher"><h2>Change theme</h2><ul>';
		var themes = [
			'osx', 
			'bright-and-shiny', 
			'planet-sky-bright', 
			'bright-fantasy-worldwide', 
			'too-bright-grass', 
			'beautiful-sea', 
			'bright-blue-water', 
			'life', 
			'clown-fish'
		];

		for (var i = 0; i < themes.length; i++) {
			var theme = themes[i];
			var title = theme.charAt(0).toUpperCase() + theme.substr(1).replace(/-/g, ' ');

			html += '<li><a href="#' + theme + '">' + title + '</a></li>';
		}

		html += '</ul></nav>';

		$(html).appendTo('body').find('a').click(function () {
			$('a').removeClass('login-theme-selected');

			$('body').attr('class', $(this).addClass('login-theme-selected').attr('href').substr(1));

			return false;
		}).eq(0).addClass('login-theme-selected');
	}, 

	emptyLoginBoxes: function () {
		for (var i = 0; i < 6; i++) {
			$('<div id="login-filler-' + i + '"/>').appendTo('#circle');
		}
	}, 

	loginNavigation: function () {
		var html = '<nav id="login-navigation"><ul>';

		$('#circle > *[id]').each(function () {
			var section = $(this);
			var title = section.find('h2').eq(0).text();
			var id = section.attr('id');

			html += '<li><a href="#' + id + '">' + title + '</a></li>';
		});

		html += '</ul></nav>';

		$(html).insertBefore('#circle-stage').find('a').eq(0).addClass('jquery-3d-circle-selected');
	}
};
